package com.college.statistics.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.college.commonutil.result.Result;
import com.college.statistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/staservice/daily")
@CrossOrigin //解决跨域问题
public class DailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    //统计某一天注册人数
    @PostMapping("/createStatisticsByDay/{day}")
    public Result createStatisticsByDay(@PathVariable String day){
        dailyService.createStatisticsByDay(day);
        return Result.ok();
    }
    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("/showData/{type}/{begin}/{end}")
    public Result showData(@PathVariable String type, @PathVariable String begin, @PathVariable String end){

        Map<String,Object> map = dailyService.getShowData(type,begin,end);

        return Result.ok().data(map);
    }

}
